<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="dialog-layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
			$(function() {
				$(".confirm").confirmDialog(function(data) {
					helper.showMsg(data, {
						okHandler : function() {
							art.dialog.opener.location.reload();
						}
					});
				});

				$(".dialog").frameDialog({
					width : 800,
					height : 500,
					close : function() {
						if (art.dialog.data("success")) {
							location.reload();
						}
					}
				});
			});
		</script>
		<style type="text/css">
#panTeaching {
	display: inline;
}

.teaching {
	margin-bottom: 1em;
}
</style>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<form class="form-horizontal" action="modifyLesson" method="post">
			<input type="hidden" value="${lesson.id}" name="id" />
			<fieldset>
				<legend>
					编辑课表
					<s:if test="#lesson.canceled">
						<span class="label">已取消</span>
					</s:if>
				</legend>
				<div class="control-group">
					<div class="control-label">日期</div>
					<div class="controls">
						<input type="text" name="date" id="datepicker" value="${lesson.date}" readonly="readonly" />
					</div>
				</div>
				<div class="control-group">
					<div class="control-label">起止时间</div>
					<div class="controls">
						<div class="input-append bootstrap-timepicker">
							<input name="beginTime" class="lessonTime input-small" type="text" value="${lesson.beginTimeStr}" readonly="readonly">
							<span class="add-on">
								<i class="icon-time"></i>
							</span>
						</div>
						<div class="input-append bootstrap-timepicker">
							<input name="endTime" class="lessonTime input-small" type="text" value="${lesson.endTimeStr}" readonly="readonly">
							<span class="add-on">
								<i class="icon-time"></i>
							</span>
						</div>
					</div>
				</div>
				<div class="control-group">
					<div class="control-label">课程名称</div>
					<div class="controls">
						<input type="text" name="name" value="${lesson.name }" readonly="readonly" />
					</div>
				</div>
				<div class="control-group">
					<div class="control-label">教员</div>
					<div class="controls">
						<s:iterator value="#lesson.teachings" var="teaching" status="status">
							<div class="teaching">
								<s:select list="#teachers" name="teacher" listKey="id" listValue="name" value="teacher.id" readonly="readonly" />
								<div class="input-append bootstrap-timepicker">
									<input class="beginTime teachingTime input-small" name="teachingBeginTime" type="text" value="${teaching.beginTimeStr}" readonly="readonly">
									<span class="add-on">
										<i class="icon-time"></i>
									</span>
								</div>
								<div class="input-append bootstrap-timepicker">
									<input class="endTime teachingTime input-small" name="teachingEndTime" type="text" value="${teaching.endTimeStr}" readonly="readonly">
									<span class="add-on">
										<i class="icon-time"></i>
									</span>
								</div>
							</div>
						</s:iterator>
					</div>
				</div>
				<div class="control-group">
					<div class="control-label">教室</div>
					<div class="controls">
						<s:select list="#classrooms" name="classroom" listKey="id" listValue="name" value="#lesson.classroom.id" readonly="readonly" />
					</div>
				</div>
				<div class="control-group">
					<div class="control-label">所属课程类型</div>
					<div class="controls">
						<select name="courseType" readonly="readonly">
							<s:iterator value="#courseTypes" var="courseType">
								<option class="${courseType.cssClass}" value="${courseType.id}" <s:if test="id==#lesson.courseType.id">selected="selected" </s:if>>${courseType.name}</option>
							</s:iterator>
						</select>
					</div>
				</div>
			</fieldset>
			<div class="control-group">
				<div class="controls">
					<s:url namespace="/lesson" action="modifyLesson" id="modifyLesson">
						<s:param name="id" value="#lesson.id"></s:param>
					</s:url>
					<a class="btn btn-primary" href="${modifyLesson}">编辑</a>
					<s:url namespace="/lesson" action="doRemoveLesson" id="doRemoveLesson">
						<s:param name="id" value="#lesson.id"></s:param>
					</s:url>
					<a class="btn confirm" href="${doRemoveLesson}" title="删除该课表">删除</a>
					<s:if test="#lesson.canceled">
						<s:url namespace="/lesson" action="doResumeLesson" id="doResumeLesson">
							<s:param name="id" value="#lesson.id"></s:param>
						</s:url>
						<a class="btn confirm" href="${doResumeLesson}" title="恢复该课表">恢复</a>
					</s:if>
					<s:else>
						<s:url namespace="/lesson" action="doCancelLesson" id="doCancelLesson">
							<s:param name="id" value="#lesson.id"></s:param>
						</s:url>
						<a class="btn confirm" href="${doCancelLesson}" title="取消该课表">取消</a>
					</s:else>
				</div>
			</div>
		</form>
	</tiles:putAttribute>
</tiles:insertDefinition>